home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / src / brailler-04b-c / brlr ƒ / Shell ƒ / graphics dispatch.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-23  |  8.9 KB  |  484 lines  |  [TEXT/MMCC]

  1. #include "graphics dispatch.h"
  2. #include "window layer.h"
  3. #include "program globals.h"
  4. #include "edit functions.h"
  5. #include "about.h"
  6. #include "about MSG.h"
  7. #include "other MSG window.h"
  8. #include "help.h"
  9. #include "brlr main window.h"
  10. #include "brlr floating window.h"
  11.  
  12. extern    Boolean            gPostingEvents;
  13.  
  14. enum DispatchError SetupWindowDispatch(short index, WindowPtr theWindow)
  15. {
  16.     SetWindowIndex(theWindow, index);
  17.     SetWindowTE(theWindow, 0L);
  18.     SetWindowVScrollBar(theWindow, 0L);
  19.     SetWindowHScrollBar(theWindow, 0L);
  20.     
  21.     switch (index)
  22.     {
  23.         case kAboutWindow:
  24.             SetupTheAboutWindow(theWindow);
  25.             return kSuccess;
  26.         case kAboutMSGWindow:
  27.             SetupTheAboutMSGWindow(theWindow);
  28.             return kSuccess;
  29.         case kOtherMSGWindow:
  30.             SetupTheOtherMSGWindow(theWindow);
  31.             return kSuccess;
  32.         case kHelpWindow:
  33.             SetupTheHelpWindow(theWindow);
  34.             return kSuccess;
  35.         case kMainWindow:
  36.             SetupTheMainWindow(theWindow);
  37.             return kSuccess;
  38.         case kFloatingWindow:
  39.             SetupTheFloatingWindow(theWindow);
  40.             return kSuccess;
  41.     }
  42.     
  43.     return kFailure;
  44. }
  45.  
  46. enum DispatchError ShutdownWindowDispatch(short index)
  47. {
  48.     switch (index)
  49.     {
  50.         case kAboutMSGWindow:
  51.             ShutDownTheAboutMSGWindow();
  52.             return kSuccess;
  53.         case kHelpWindow:
  54.             ShutDownTheHelpWindow();
  55.             return kSuccess;
  56.         case kMainWindow:
  57.             ShutDownTheMainWindow();
  58.             return kSuccess;
  59.         case kFloatingWindow:
  60.             ShutDownTheFloatingWindow();
  61.             return kSuccess;
  62.     }
  63.     
  64.     return kFailure;
  65. }
  66.  
  67. enum DispatchError OpenWindowDispatch(short index)
  68. {
  69.     WindowPtr        theWindow;
  70.     
  71.     theWindow=GetIndWindowPtr(index);
  72.     
  73.     switch (index)
  74.     {
  75.         case kAboutWindow:
  76.             OpenTheAboutWindow(theWindow);
  77.             return kSuccess;
  78.         case kAboutMSGWindow:
  79.             OpenTheMSGWindow(theWindow);
  80.             return kSuccess;
  81.         case kOtherMSGWindow:
  82.             OpenTheOtherMSGWindow(theWindow);
  83.             return kSuccess;
  84.         case kMainWindow:
  85.             OpenTheMainWindow(theWindow);
  86.             return kSuccess;
  87.         case kFloatingWindow:
  88.             OpenTheFloatingWindow(theWindow);
  89.             return kSuccess;
  90.     }
  91.     
  92.     return kFailure;
  93. }
  94.  
  95. enum DispatchError CloseWindowDispatch(short index)
  96. {
  97.     WindowPtr        theWindow;
  98.     
  99.     theWindow=GetIndWindowPtr(index);
  100.     
  101.     switch (index)
  102.     {
  103.         case kMainWindow:
  104.             if (CloseTheMainWindow(theWindow))
  105.                 return kSuccess;
  106.             else
  107.                 return kCancel;
  108.         case kFloatingWindow:
  109.             CloseTheFloatingWindow(theWindow);
  110.             return kSuccess;
  111.     }
  112.     
  113.     return kFailure;
  114. }
  115.  
  116. enum DispatchError DisposeWindowDispatch(short index)
  117. {
  118.     WindowPtr        theWindow;
  119.     
  120.     theWindow=GetIndWindowPtr(index);
  121.     
  122.     switch (index)
  123.     {
  124.         case kOtherMSGWindow:
  125.             DisposeTheOtherMSGWindow(theWindow);
  126.             return kSuccess;
  127.         case kMainWindow:
  128.             DisposeTheMainWindow(theWindow);
  129.             return kSuccess;
  130.         case kFloatingWindow:
  131.             DisposeTheFloatingWindow(theWindow);
  132.             return kSuccess;
  133.     }
  134.     
  135.     return kFailure;
  136. }
  137.  
  138. enum DispatchError DrawWindowDispatch(short index, short theDepth)
  139. {
  140.     WindowPtr        theWindow;
  141.     
  142.     theWindow=GetIndWindowPtr(index);
  143.     
  144.     switch (index)
  145.     {
  146.         case kAboutWindow:
  147.             DrawTheAboutWindow(theWindow, theDepth);
  148.             return kSuccess;
  149.         case kAboutMSGWindow:
  150.             DrawTheAboutMSGWindow(theWindow, theDepth);
  151.             return kSuccess;
  152.         case kHelpWindow:
  153.             DrawTheHelpWindow(theWindow, theDepth);
  154.             return kSuccess;
  155.         case kFloatingWindow:
  156.             DrawTheFloatingWindow(theWindow, theDepth);
  157.             return kSuccess;
  158.     }
  159.     
  160.     return kFailure;
  161. }
  162.  
  163. enum DispatchError ChangeDepthDispatch(short index, short newDepth)
  164. {
  165.     WindowPtr        theWindow;
  166.     
  167.     theWindow=GetIndWindowPtr(index);
  168.     
  169.     switch (index)
  170.     {
  171.         case kAboutMSGWindow:
  172.             ChangeDepthTheAboutMSGWindow(theWindow, newDepth);
  173.             return kSuccess;
  174.     }
  175.     
  176.     return kFailure;
  177. }
  178.  
  179. enum DispatchError CopybitsDispatch(short index, WindowPtr offscreenWindow)
  180. {
  181.     WindowPtr        theWindow;
  182.     
  183.     theWindow=GetIndWindowPtr(index);
  184.     
  185.     switch (index)
  186.     {
  187.         case kOtherMSGWindow:
  188.             CopybitsTheOtherMSGWindow(theWindow, offscreenWindow);
  189.             return kSuccess;
  190.         case kMainWindow:
  191.             CopybitsTheMainWindow(theWindow, offscreenWindow);
  192.             return kSuccess;
  193.     }
  194.     
  195.     return kFailure;
  196. }
  197.  
  198. enum DispatchError IdleWindowDispatch(short index, Point mouseLoc)
  199. {
  200.     WindowPtr        theWindow;
  201.     
  202.     theWindow=GetIndWindowPtr(index);
  203.     
  204.     switch (index)
  205.     {
  206.         case kMainWindow:
  207.             IdleInMainWindow(theWindow, mouseLoc);
  208.             return kSuccess;
  209.         case kFloatingWindow:
  210.             IdleInFloatingWindow(theWindow, mouseLoc);
  211.             return kPassThrough;
  212.     }
  213.     
  214.     return kFailure;
  215. }
  216.  
  217. enum DispatchError ActivateWindowDispatch(short index)
  218. {
  219.     WindowPtr        theWindow;
  220.     
  221.     theWindow=GetIndWindowPtr(index);
  222.     
  223.     switch (index)
  224.     {
  225.         case kOtherMSGWindow:
  226.             ActivateTheOtherMSGWindow(theWindow);
  227.             return kSuccess;
  228.         case kMainWindow:
  229.             ActivateTheMainWindow(theWindow);
  230.             return kSuccess;
  231.         case kFloatingWindow:
  232.             ActivateTheFloatingWindow(theWindow);
  233.             return kSuccess;
  234.     }
  235.     
  236.     return kFailure;
  237. }
  238.  
  239. enum DispatchError DeactivateWindowDispatch(short index)
  240. {
  241.     WindowPtr        theWindow;
  242.     
  243.     theWindow=GetIndWindowPtr(index);
  244.     
  245.     switch (index)
  246.     {
  247.         case kOtherMSGWindow:
  248.             DeactivateTheOtherMSGWindow(theWindow);
  249.             return kSuccess;
  250.         case kMainWindow:
  251.             DeactivateTheMainWindow(theWindow);
  252.             return kSuccess;
  253.         case kFloatingWindow:
  254.             DeactivateTheFloatingWindow(theWindow);
  255.             return kSuccess;
  256.     }
  257.     
  258.     return kFailure;
  259. }
  260.  
  261. enum DispatchError GrowWindowDispatch(short index)
  262. {
  263.     WindowPtr        theWindow;
  264.     
  265.     theWindow=GetIndWindowPtr(index);
  266.     
  267.     switch (index)
  268.     {
  269.         case kOtherMSGWindow:
  270.             ResizeControlsInOtherMSGWindow(theWindow);
  271.             return kSuccess;
  272.         case kMainWindow:
  273.             ResizeControlsInMainWindow(theWindow);
  274.             return kSuccess;
  275.     }
  276.     
  277.     return kFailure;
  278. }
  279.  
  280. enum DispatchError ZoomWindowDispatch(short index)
  281. {
  282.     WindowPtr        theWindow;
  283.     
  284.     theWindow=GetIndWindowPtr(index);
  285.     
  286.     switch (index)
  287.     {
  288.         case kOtherMSGWindow:
  289.             ResizeControlsInOtherMSGWindow(theWindow);
  290.             return kSuccess;
  291.         case kMainWindow:
  292.             ResizeControlsInMainWindow(theWindow);
  293.             return kSuccess;
  294.     }
  295.     
  296.     return kFailure;
  297. }
  298.  
  299. enum DispatchError GetGrowSizeDispatch(short index, Rect *sizeRect)
  300. {
  301.     WindowPtr        theWindow;
  302.     
  303.     theWindow=GetIndWindowPtr(index);
  304.     
  305.     switch (index)
  306.     {
  307.         case kOtherMSGWindow:
  308.             GetGrowSizeOtherMSGWindow(theWindow, sizeRect);
  309.             return kSuccess;
  310.         case kMainWindow:
  311.             GetGrowSizeMainWindow(theWindow, sizeRect);
  312.             return kSuccess;
  313.     }
  314.     
  315.     return kFailure;
  316. }
  317.  
  318. enum DispatchError KeyDownDispatch(short index, unsigned char theChar)
  319. {
  320.     WindowPtr        theWindow;
  321.     
  322.     theWindow=GetIndWindowPtr(index);
  323.     
  324.     switch (index)
  325.     {
  326.         case kAboutWindow:
  327.             KeyDownInAboutWindow(theWindow, theChar);
  328.             return kSuccess;
  329.         case kOtherMSGWindow:
  330.             KeyPressedInOtherMSGWindow(theWindow, theChar);
  331.             return kSuccess;
  332.         case kHelpWindow:
  333.             KeyPressedInHelpWindow(theWindow, theChar);
  334.             return kSuccess;
  335.         case kMainWindow:
  336.             KeyPressedInMainWindow(theWindow, theChar);
  337.             return kSuccess;
  338.         case kFloatingWindow:
  339.             if ((gPostingEvents) || (GetFrontDocumentWindow()!=GetIndWindowPtr(kMainWindow)))
  340.                 return kPassThrough;
  341.             else
  342.                 KeyPressedInFloatingWindow(theWindow, theChar);
  343.             return kSuccess;
  344.     }
  345.     
  346.     return kFailure;
  347. }
  348.  
  349. enum DispatchError MouseDownDispatch(short index, Point thePoint)
  350. {
  351.     WindowPtr        theWindow;
  352.     
  353.     theWindow=GetIndWindowPtr(index);
  354.     
  355.     switch (index)
  356.     {
  357.         case kAboutWindow:
  358.             MouseDownInAboutWindow(theWindow, thePoint);
  359.             return kSuccess;
  360.         case kOtherMSGWindow:
  361.             MouseClickedInOtherMSGWindow(theWindow, thePoint);
  362.             return kSuccess;
  363.         case kHelpWindow:
  364.             MouseClickedInHelpWindow(theWindow, thePoint);
  365.             return kSuccess;
  366.         case kMainWindow:
  367.             MouseClickedInMainWindow(theWindow, thePoint);
  368.             return kSuccess;
  369.         case kFloatingWindow:
  370.             MouseClickedInFloatingWindow(theWindow, thePoint);
  371.             return kSuccess;
  372.     }
  373.     
  374.     return kFailure;
  375. }
  376.  
  377. enum DispatchError UndoDispatch(short index)
  378. {
  379.     switch (index)
  380.     {
  381.         case kFloatingWindow:
  382.             return kPassThrough;
  383.             break;
  384.     }
  385.     
  386.     return kFailure;
  387. }
  388.  
  389. enum DispatchError CutDispatch(short index)
  390. {
  391.     WindowPtr        theWindow;
  392.     
  393.     theWindow=GetIndWindowPtr(index);
  394.     
  395.     switch (index)
  396.     {
  397.         case kMainWindow:
  398.             GenericCut(theWindow);
  399.             return kSuccess;
  400.             break;
  401.         case kFloatingWindow:
  402.             return kPassThrough;
  403.             break;
  404.     }
  405.     
  406.     return kFailure;
  407. }
  408.  
  409. enum DispatchError CopyDispatch(short index)
  410. {
  411.     WindowPtr        theWindow;
  412.     
  413.     theWindow=GetIndWindowPtr(index);
  414.     
  415.     switch (index)
  416.     {
  417.         case kMainWindow:
  418.             GenericCopy(theWindow);
  419.             return kSuccess;
  420.         case kFloatingWindow:
  421.             return kPassThrough;
  422.             break;
  423.     }
  424.     
  425.     return kFailure;
  426. }
  427.  
  428. enum DispatchError PasteDispatch(short index)
  429. {
  430.     WindowPtr        theWindow;
  431.     
  432.     theWindow=GetIndWindowPtr(index);
  433.     
  434.     switch (index)
  435.     {
  436.         case kMainWindow:
  437.             GenericPaste(theWindow);
  438.             return kSuccess;
  439.         case kFloatingWindow:
  440.             return kPassThrough;
  441.             break;
  442.     }
  443.     
  444.     return kFailure;
  445. }
  446.  
  447. enum DispatchError ClearDispatch(short index)
  448. {
  449.     WindowPtr        theWindow;
  450.     
  451.     theWindow=GetIndWindowPtr(index);
  452.     
  453.     switch (index)
  454.     {
  455.         case kMainWindow:
  456.             GenericClear(theWindow);
  457.             return kSuccess;
  458.         case kFloatingWindow:
  459.             return kPassThrough;
  460.             break;
  461.     }
  462.     
  463.     return kFailure;
  464. }
  465.  
  466. enum DispatchError SelectAllDispatch(short index)
  467. {
  468.     WindowPtr        theWindow;
  469.     
  470.     theWindow=GetIndWindowPtr(index);
  471.     
  472.     switch (index)
  473.     {
  474.         case kMainWindow:
  475.             GenericSelectAll(theWindow);
  476.             return kSuccess;
  477.         case kFloatingWindow:
  478.             return kPassThrough;
  479.             break;
  480.     }
  481.     
  482.     return kFailure;
  483. }
  484.